class Solution(object):
    def validWordSquare(self, words):
        """
        :type words: List[str]
        :rtype: bool
        """
        m = len(words)
        for i in range(m):
            for j in range(len(words[i])):
                if j >= m:
                    return False
                else:
                    if len(words[j]) < i + 1:
                        return False
                    else:
                        if words[i][j] != words[j][i]:
                            return False
        return True


data = Solution()
# words = ["abcd", "bnrt", "crmy", "dtye"]
# print(data.validWordSquare(words))
# words = ["ball", "asee", "let", "lep"]
# print(data.validWordSquare(words))
words = ["b", "abc"]
print(data.validWordSquare(words))
